<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  
  <meta http-equiv="X-UA-Compatible" content="IE=edge" >
  <title>创建CoreData基本教程 | Grx Blog</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="description" content="工程中引入CoreData步骤:1.添加CoreData Framework框架
2.创建Data Model（数据模型）          New File -&amp;gt; Core Data -&amp;gt; Data Model
3.添加实体表和属性          Data Model -&amp;gt; Add Entity -&amp;gt;Add Attributes添加字段属性
4.创建实体对象类">
<meta property="og:type" content="article">
<meta property="og:title" content="创建CoreData基本教程">
<meta property="og:url" content="http://yoursite.com/2015/05/15/创建CoreData基本教程/index.html">
<meta property="og:site_name" content="Grx Blog">
<meta property="og:description" content="工程中引入CoreData步骤:1.添加CoreData Framework框架
2.创建Data Model（数据模型）          New File -&amp;gt; Core Data -&amp;gt; Data Model
3.添加实体表和属性          Data Model -&amp;gt; Add Entity -&amp;gt;Add Attributes添加字段属性
4.创建实体对象类">
<meta property="og:updated_time" content="2016-05-10T05:04:06.000Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="创建CoreData基本教程">
<meta name="twitter:description" content="工程中引入CoreData步骤:1.添加CoreData Framework框架
2.创建Data Model（数据模型）          New File -&amp;gt; Core Data -&amp;gt; Data Model
3.添加实体表和属性          Data Model -&amp;gt; Add Entity -&amp;gt;Add Attributes添加字段属性
4.创建实体对象类">
  
    <link rel="alternative" href="/atom.xml" title="Grx Blog" type="application/atom+xml">
  
  
    <link rel="icon" href="/favicon.png">
  
  <link rel="stylesheet" href="/css/style.css">
</head>

<body>
  <div id="container">
    <div class="left-col">
    <div class="overlay"></div>
<div class="intrude-less">
	<header id="header" class="inner">
		<a href="/" class="profilepic">
			
			<img lazy-src="/img/rufei.jpg" class="js-avatar">
			
		</a>

		<hgroup>
		  <h1 class="header-author"><a href="/">Grx</a></h1>
		</hgroup>

		
		<p class="header-subtitle">自我管理，知识管理，时间管理，阅读，语音写作，思维导图</p>
		

		
			<div class="switch-btn">
				<div class="icon">
					<div class="icon-ctn">
						<div class="icon-wrap icon-house" data-idx="0">
							<div class="birdhouse"></div>
							<div class="birdhouse_holes"></div>
						</div>
						<div class="icon-wrap icon-ribbon hide" data-idx="1">
							<div class="ribbon"></div>
						</div>
						
						<div class="icon-wrap icon-link hide" data-idx="2">
							<div class="loopback_l"></div>
							<div class="loopback_r"></div>
						</div>
						
						
						<div class="icon-wrap icon-me hide" data-idx="3">
							<div class="user"></div>
							<div class="shoulder"></div>
						</div>
						
					</div>
					
				</div>
				<div class="tips-box hide">
					<div class="tips-arrow"></div>
					<ul class="tips-inner">
						<li>菜单</li>
						<li>标签</li>
						
						<li>友情链接</li>
						
						
						<li>关于我</li>
						
					</ul>
				</div>
			</div>
		

		<div class="switch-area">
			<div class="switch-wrap">
				<section class="switch-part switch-part1">
					<nav class="header-menu">
						<ul>
						
							<li><a href="/">主页</a></li>
				        
							<li><a href="/tags/life">随笔</a></li>
				        
							<li><a href="/archives">所有文章</a></li>
				        
						</ul>
					</nav>
					<nav class="header-nav">
						<div class="social">
							
								<a class="github" target="_blank" href="https://github.com/ruixiaoguo" title="github">github</a>
					        
								<a class="weibo" target="_blank" href="https://weibo.com/u/3984935859?refer_flag=1005055010_" title="weibo">weibo</a>
					        
								<a class="rss" target="_blank" href="#" title="rss">rss</a>
					        
								<a class="zhihu" target="_blank" href="#" title="zhihu">zhihu</a>
					        
						</div>
					</nav>
				</section>
				
				
				<section class="switch-part switch-part2">
					<div class="widget tagcloud" id="js-tagcloud">
						<a href="/tags/OC/" style="font-size: 10px;">-OC</a> <a href="/tags/Android/" style="font-size: 10px;">Android</a> <a href="/tags/Apple-Watch/" style="font-size: 10px;">Apple Watch</a> <a href="/tags/Flutter/" style="font-size: 13.33px;">Flutter</a> <a href="/tags/Life/" style="font-size: 10px;">Life</a> <a href="/tags/Lottie/" style="font-size: 10px;">Lottie</a> <a href="/tags/MMKV/" style="font-size: 10px;">MMKV</a> <a href="/tags/MonkeyKing/" style="font-size: 10px;">MonkeyKing</a> <a href="/tags/OC/" style="font-size: 20px;">OC</a> <a href="/tags/RAC/" style="font-size: 11.67px;">RAC</a> <a href="/tags/Swift/" style="font-size: 15px;">Swift</a> <a href="/tags/WKWebView/" style="font-size: 10px;">WKWebView</a> <a href="/tags/WebView/" style="font-size: 10px;">WebView</a> <a href="/tags/Xcode/" style="font-size: 18.33px;">Xcode</a> <a href="/tags/appledoc/" style="font-size: 10px;">appledoc</a> <a href="/tags/hexo/" style="font-size: 11.67px;">hexo</a> <a href="/tags/ios/" style="font-size: 10px;">ios</a> <a href="/tags/life/" style="font-size: 16.67px;">life</a> <a href="/tags/xcode/" style="font-size: 10px;">xcode</a>
					</div>
				</section>
				
				
				
				<section class="switch-part switch-part3">
					<div id="js-friends">
					
			          <a target="_blank" class="main-nav-link switch-friends-link" href="http://blog.devtang.com">唐巧的博客</a>
			        
			          <a target="_blank" class="main-nav-link switch-friends-link" href="http://beyondvincent.com">破船之家</a>
			        
			          <a target="_blank" class="main-nav-link switch-friends-link" href="http://limboy.me">无网不剩</a>
			        
			          <a target="_blank" class="main-nav-link switch-friends-link" href="http://msching.github.io">码农人生</a>
			        
			          <a target="_blank" class="main-nav-link switch-friends-link" href="http://yulingtianxia.com">玉令天下</a>
			        
			          <a target="_blank" class="main-nav-link switch-friends-link" href="http://blog.leichunfeng.com">雷纯锋的技术博客</a>
			        
			          <a target="_blank" class="main-nav-link switch-friends-link" href="http://jax.cnblogs.com">包建强</a>
			        
			          <a target="_blank" class="main-nav-link switch-friends-link" href="http://blog.cnbang.net">bang</a>
			        
			        </div>
				</section>
				

				
				
				<section class="switch-part switch-part4">
				
					<div id="js-aboutme">知识管理，时间管理，自我管理，阅读，语音写作，思维导图，Wiz，TimeMeter</div>
				</section>
				
			</div>
		</div>
	</header>				
</div>

    </div>
    <div class="mid-col">
      <nav id="mobile-nav">
  	<div class="overlay">
  		<div class="slider-trigger"></div>
  		<h1 class="header-author js-mobile-header hide">Grx</h1>
  	</div>
	<div class="intrude-less">
		<header id="header" class="inner">
			<div class="profilepic">
			
				<img lazy-src="/img/rufei.jpg" class="js-avatar">
			
			</div>
			<hgroup>
			  <h1 class="header-author">Grx</h1>
			</hgroup>
			
			<p class="header-subtitle">自我管理，知识管理，时间管理，阅读，语音写作，思维导图</p>
			
			<nav class="header-menu">
				<ul>
				
					<li><a href="/">主页</a></li>
		        
					<li><a href="/tags/life">随笔</a></li>
		        
					<li><a href="/archives">所有文章</a></li>
		        
		        <div class="clearfix"></div>
				</ul>
			</nav>
			<nav class="header-nav">
				<div class="social">
					
						<a class="github" target="_blank" href="https://github.com/ruixiaoguo" title="github">github</a>
			        
						<a class="weibo" target="_blank" href="https://weibo.com/u/3984935859?refer_flag=1005055010_" title="weibo">weibo</a>
			        
						<a class="rss" target="_blank" href="#" title="rss">rss</a>
			        
						<a class="zhihu" target="_blank" href="#" title="zhihu">zhihu</a>
			        
				</div>
			</nav>
		</header>				
	</div>
</nav>

      <div class="body-wrap"><article id="post-创建CoreData基本教程" class="article article-type-post" itemscope itemprop="blogPost">
  
    <div class="article-meta">
      <a href="/2015/05/15/创建CoreData基本教程/" class="article-date">
  	<time datetime="2015-05-15T03:22:59.000Z" itemprop="datePublished">2015-05-15</time>
</a>
    </div>
  
  <div class="article-inner">
    
      <input type="hidden" class="isFancy" />
    
    
      <header class="article-header">
        
  
    <h1 class="article-title" itemprop="name">
      创建CoreData基本教程
    </h1>
  

      </header>
      
      <div class="article-info article-info-post">
        
	<div class="article-tag tagcloud">
		<ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/Xcode/">Xcode</a></li></ul>
	</div>

        

        <div class="clearfix"></div>
      </div>
      
    
    <div class="article-entry" itemprop="articleBody">
      
        <h4 id="工程中引入CoreData步骤"><a href="#工程中引入CoreData步骤" class="headerlink" title="工程中引入CoreData步骤:"></a>工程中引入CoreData步骤:</h4><p>1.添加CoreData Framework框架</p>
<p>2.创建Data Model（数据模型）<br>          New File -&gt; Core Data -&gt; Data Model</p>
<p>3.添加实体表和属性<br>          Data Model -&gt; Add Entity -&gt;Add Attributes添加字段属性</p>
<p>4.创建实体对象类<br><a id="more"></a><br>   方法1：选中Entity：Xcode的菜单Editor -&gt; Create NSManagedObject SubClass…<br>                        这样可以自动生成与实体表相关连的实体类.h.m.<br>                        选择实体表 查看属性，名称和关联类名应该都已经是自动关联成功的了。</p>
<p>   方法2：如果手动创建实体类.h.m文件，那么要手动实现与实体表的关联，否则实体表默认关联NSManagedObject，这样就会造成错误。</p>
<p>PS:个人项目中曾出现过类似的错误，生成实体之后实体调用它的实例方法会崩溃，实体不能识别它的实体方法。</p>
<p>5.编写coreData代码</p>
<p>首先说明，这部分编写的代码是为了引入CoreData到工程中，可以新建一个包含CoreData的空白工程，然后完全Copy其AppDegate中的引入CoreData方法即可。</p>
<p><br><br>代码部分：</p>
<pre><code>&lt;1&gt;AppDelegate中引入头文件
#import &lt;CoreData/CoreData.h&gt;
</code></pre><hr>
<pre><code>   &lt;2&gt;增加属性及方法声明
  // 上下文对象      @property(readonly,retain,nonatomic)NSManagedObjectContext *managedObjectContext;
  // 数据模型
@property (readonly,retain,nonatomic)NSManagedObjectModel *managedObjectModel;
 // 协调者
@property (readonly,retain,nonatomic)NSPersistentStoreCoordinator *persistentStoreCoordinator;

 // 在应用程序终止的时候会调用该方法
- (void)saveContext;
// 得到应用程序的 Documents 路径, 将数据库存在此目录下   
- (NSURL *)applicationDocumentsDirectory;
</code></pre><hr>
<pre><code>&lt;3&gt;AppDelegate.m 文件会多出如下几个方法:

- (void)applicationWillTerminate:(UIApplication *)application
{
 // 保存上下文对象的方法在此调用(程序结束的时候)
 [self saveContext];
}

#pragma makr - save context
- (void)saveContext
{
    // 程序意外终止就会调用此方法
    NSError *error = nil;
    NSManagedObjectContext *managedObjectContext = self.managedObjectContext;
   if (managedObjectContext != nil) { 
           if ([managedObjectContext hasChanges] &amp;&amp; ![managedObjectContext save:&amp;error]) {
                        NSLog(@&quot;Unresolved error %@, %@&quot;, error, [error userInfo]);
        abort();
        } 
    }
}
</code></pre><hr>
<pre><code>AppDelegate.m中实现CoreData方法

 #pragma mark - Core Data stack
- (NSManagedObjectContext *)managedObjectContext
{ 
    // 创建上下文对象
 if (_managedObjectContext != nil) {
     return _managedObjectContext;
 }

 NSPersistentStoreCoordinator *coordinator = [self persistentStoreCoordinator];
 if (coordinator != nil) {
     _managedObjectContext = [[NSManagedObjectContext alloc] init];
    [_managedObjectContext setPersistentStoreCoordinator:coordinator];
 }
return _managedObjectContext;
 }

- (NSManagedObjectModel *)managedObjectModel
{
 // 创建数据模型
if (_managedObjectModel != nil) {
     return _managedObjectModel;
 }
 NSURL *modelURL = [[NSBundle mainBundle] URLForResource:@&quot;CoreDataDemo02&quot; withExtension:@&quot;momd&quot;];
 _managedObjectModel = [[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL];
 return _managedObjectModel;
 }
- (NSPersistentStoreCoordinator *)persistentStoreCoordinator
{
 // 创建协调者,也就是存储区
 if (_persistentStoreCoordinator != nil) {
     return _persistentStoreCoordinator;
 }

 NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@&quot;CoreDataDemo02.sqlite&quot;];

 NSError *error = nil;
 _persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]];
 if (![_persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:nil error:&amp;error]) {
     NSLog(@&quot;Unresolved error %@, %@&quot;, error, [error userInfo]);
     abort();
 }    

 return _persistentStoreCoordinator;
 }

#pragma mark - Application&apos;s Documents directory
    - (NSURL *)applicationDocumentsDirectory
{
 // 得到 Documents 目录
 return [[[NSFileManager defaultManager] 
          URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject];

  }  
</code></pre><hr>
<h4 id="第二-CoreData的增删查-以persion为例"><a href="#第二-CoreData的增删查-以persion为例" class="headerlink" title="第二.CoreData的增删查:(以persion为例)"></a>第二.CoreData的增删查:(以persion为例)</h4><p>1) 写入数据</p>
<pre><code>  - (void)insertData
 {
   // 创建实体
   Person * newPerson = [NSEntityDescription insertNewObjectForEntityForName:@&quot;Person&quot; inManagedObjectContext:self.managedObjectContext];
   // 赋值
 if (newPerson != nil) {
    newPerson.firstName = @&quot;Zero&quot;;
    newPerson.lastName = @&quot;Hour&quot;;
    newPerson.age = [NSNumber numberWithInt:20];

   // 保存数据
    NSError * savingError = nil;
    if ([self.managedObjectContext save:&amp;savingError]) {
        NSLog(@&quot;success&quot;);
    }else {
        NSLog(@&quot;failed to save the context error = %@&quot;, savingError);
    }
}else {
    NSLog(@&quot;failed to create the new person&quot;);
    }
}
</code></pre><hr>
<p>2) 删除数据</p>
<pre><code> - (void)deleteData
 {
     NSFetchRequest * fetchRequest = [[NSFetchRequest alloc] init];
     NSEntityDescription * entity = [NSEntityDescription entityForName:@&quot;Person&quot; inManagedObjectContext:self.managedObjectContext];
    [fetchRequest setEntity:entity];

    NSError * requestError = nil;
    NSArray * persons = [self.managedObjectContext executeFetchRequest:fetchRequest error:&amp;requestError];

   if ([persons count] &gt; 0) {

    Person * lastPerson = [persons lastObject];
    // 删除数据
    [self.managedObjectContext deleteObject:lastPerson];
    if ([lastPerson isDeleted]) {
        NSLog(@&quot;successfully deleted the last person&quot;);
        NSError * savingError = nil;
        if ([self.managedObjectContext save:&amp;savingError]) {
            NSLog(@&quot;successfully saved the context&quot;);

        }else {
            NSLog(@&quot;failed to save the context error = %@&quot;, savingError);
        }
    }else {

        NSLog(@&quot;failed to delete the last person&quot;);
    }
}else {
        NSLog(@&quot;could not find any person entity in the context&quot;);
    }
}
</code></pre><hr>
<p>3) 更改数据</p>
<pre><code>- (void)updateData
 {
     NSFetchRequest * fetchRequest = [[NSFetchRequest alloc] init];
     NSEntityDescription * entity = [NSEntityDescription entityForName:@&quot;Person&quot; inManagedObjectContext:self.managedObjectContext];
   [fetchRequest setEntity:entity];

   NSError * requestError = nil;
   NSArray * persons = [self.managedObjectContext executeFetchRequest:fetchRequest error:&amp;requestError];

   if ([persons count] &gt; 0) {

   Person * lastPerson = [persons lastObject];
   // 更新数据
   lastPerson.firstName = @&quot;Hour&quot;;
   lastPerson.lastName = @&quot;Zero&quot;;
   lastPerson.age = @21;

   NSError * savingError = nil;
   if ([self.managedObjectContext save:&amp;savingError]) {
      NSLog(@&quot;successfully saved the context&quot;);

   }else {
      NSLog(@&quot;failed to save the context error = %@&quot;, savingError);
   }
}else {
     NSLog(@&quot;could not find any person entity in the context&quot;);
    }
}
</code></pre><hr>
<p> 4) 查询数据</p>
<pre><code>  - (void)findData
    {
        NSFetchRequest * fetchRequest = [[NSFetchRequest alloc] init];
        NSEntityDescription * entity = [NSEntityDescription entityForName:@&quot;Person&quot; inManagedObjectContext:self.managedObjectContext];
       [fetchRequest setEntity:entity];

  // 设置排序条件
  NSSortDescriptor * ageSort = [[NSSortDescriptor alloc] initWithKey:@&quot;age&quot; ascending:YES];
  NSSortDescriptor * firstNameSort = [[NSSortDescriptor alloc] initWithKey:@&quot;firstName&quot; ascending:YES];
  NSArray * sortDescriptors = @[ageSort, firstNameSort];
 [fetchRequest setSortDescriptors:sortDescriptors];

 // 设置查询条件
 NSPredicate * agePre = [NSPredicate predicateWithFormat:@&quot;age &gt; 18&quot;];
[fetchRequest setPredicate:agePre];

NSError * requestError = nil;
NSArray * persons = [self.managedObjectContext executeFetchRequest:fetchRequest error:&amp;requestError];
int counter = 0;
for (Person * thisPerson in persons) {
    NSLog(@&quot;person--&gt;%d, firstName = %@, lastName = %@, age = %d&quot;, counter, thisPerson.firstName, thisPerson.lastName, [thisPerson.age intValue]);
    counter ++;
    }
 }
</code></pre><hr>
<h4 id="第三-实体表关系及属性"><a href="#第三-实体表关系及属性" class="headerlink" title="第三.实体表关系及属性:"></a>第三.实体表关系及属性:</h4><p>增加实体表关系:Entity -&gt; Add RelationShip 或者 选中Entity，按住Control键，拖向创建关系的表。这种方式会自动创建反相关联</p>
<p><1>关系名称必须首字母小写</1></p>
<p><2>Apple建议每一个关系都创建一个反向关系(inverse)。没有反向关联的话会有一个数据库警告</2></p>
<p><3>To-Many Relationship属性，代表着一对多的关系，一个实体可以关联多个。</3></p>
<p><4>Delete Rule选项可以选择Cascade，实现级联删除，表示在使用Core Data删除表的一个对象时，与其关联的其他表的对象也将被一起删除。</4></p>
<h4 id="第四-实体属性字段"><a href="#第四-实体属性字段" class="headerlink" title="第四.实体属性字段"></a>第四.实体属性字段</h4><p>增加字段Entity -&gt; Add Attributes</p>
<p><1>应该保证实体表中的字段与关联的实体类中字段一致，可以修改一次实体表就重新生成一次实体类，或者修改实体表同时手动修改实体类。</1></p>
<p><2>NSManagedObject的字段属性的实现需要使用@dynamic而非@synthsize，不需要系统生成其存取方法，有数据库负责其存取。</2></p>
<p>属性的类型(type)和(propertites)</p>
<h4 id="第五-其他相关"><a href="#第五-其他相关" class="headerlink" title="第五.其他相关"></a>第五.其他相关</h4><p>CoreData简介：</p>
<p>1.应用程序先创建或读取模型文件（后缀为xcdatamodeld）生成 NSManagedObjectModel 对象。Document应用程序是一般是通过 NSDocument 或其子类 NSPersistentDocument）从模型文件（后缀为 xcdatamodeld）读取。</p>
<p>2.然后生成 NSManagedObjectContext 和 NSPersistentStoreCoordinator 对象，前者对用户透明地调用后者对数据文件进行读写。</p>
<p>3.NSPersistentStoreCoordinator 负责从数据文件(xml, sqlite,二进制文件等)中读取数据生成 Managed Object，或保存 Managed Object 写入数据文件。</p>
<p>4.NSManagedObjectContext 参与对数据进行各种操作的整个过程，它持有 Managed Object。我们通过它来监测 Managed Object。监测数据对象有两个作用：支持 undo/redo 以及数据绑定。这个类是最常被用到的。</p>
<p>5.Model类</p>
<p> Model类包含内容:</p>
<p> Entity(实体表),为NSMnanagedObject类或者其子类，抽象数据类型。</p>
<p> Property三种属性:Attribute(用于存储实体表的基本数据),RelationShip(存储关系),FetchedRequest查询条件);</p>
<p>6.ManagedObject类</p>
<p> ManagedObject为Entity的一条记录，每一个ManagedObject被创建时 都有一个全局的NSManagedObjectID,当它别插入到ManagedObjectContext中时，可以通过ID在Context中查询到它。</p>
<p> ManagedOBjectContext管理者对数据对象的每一个操作。<br> Persistent Store Coordinator用来处理与底层硬件相关的存取操作，一般ManagedObjectContext已经完成了对它的控制和操作，我们无需关心。</p>
<p>FetchRequest</p>
<p> 7.FetchRequest与谓词NSPredicate一起作用，用来在NSManagedObjectContext中查询符合条件的实体，结果以NSArray形式给出。通常会见FetchRequest保存以重复利用。</p>

      
    </div>
    
  </div>
  
    
<nav id="article-nav">
  
    <a href="/2015/05/20/《重构》阅读笔记-代码的坏味道/" id="article-nav-newer" class="article-nav-link-wrap">
      <strong class="article-nav-caption"><</strong>
      <div class="article-nav-title">
        
          《重构》阅读笔记-代码的坏味道
        
      </div>
    </a>
  
  
    <a href="/2015/05/04/ReactiveCocoa之基础篇/" id="article-nav-older" class="article-nav-link-wrap">
      <div class="article-nav-title">ReactiveCocoa之基础篇</div>
      <strong class="article-nav-caption">></strong>
    </a>
  
</nav>

  
</article>


<div class="share_jia">
	<!-- JiaThis Button BEGIN -->
	<div class="jiathis_style">
		<span class="jiathis_txt">Share to: &nbsp; </span>
		<a class="jiathis_button_facebook"></a> 
    <a class="jiathis_button_twitter"></a>
    <a class="jiathis_button_plus"></a> 
    <a class="jiathis_button_tsina"></a>
		<a class="jiathis_button_cqq"></a>
		<a class="jiathis_button_douban"></a>
		<a class="jiathis_button_weixin"></a>
		<a class="jiathis_button_tumblr"></a>
    <a href="http://www.jiathis.com/share" class="jiathis jiathis_txt jtico jtico_jiathis" target="_blank"></a>
	</div>
	<script type="text/javascript" src="http://v3.jiathis.com/code/jia.js?uid=1405949716054953" charset="utf-8"></script>
	<!-- JiaThis Button END -->
</div>






<div class="duoshuo">
	<!-- 多说评论框 start -->
	<div class="ds-thread" data-thread-key="创建CoreData基本教程" data-title="创建CoreData基本教程" data-url="http://yoursite.com/2015/05/15/创建CoreData基本教程/"></div>
	<!-- 多说评论框 end -->
	<!-- 多说公共JS代码 start (一个网页只需插入一次) -->
	<script type="text/javascript">
	var duoshuoQuery = {short_name:"true"};
	(function() {
		var ds = document.createElement('script');
		ds.type = 'text/javascript';ds.async = true;
		ds.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//static.duoshuo.com/embed.js';
		ds.charset = 'UTF-8';
		(document.getElementsByTagName('head')[0] 
		 || document.getElementsByTagName('body')[0]).appendChild(ds);
	})();
	</script>
	<!-- 多说公共JS代码 end -->
</div>




</div>
      <footer id="footer">
  <div class="outer">
    <div id="footer-info">
    	<div class="footer-left">
    		&copy; 2019 Grx
    	</div>
      	<div class="footer-right">
      		<a href="http://hexo.io/" target="_blank">Hexo</a>  Theme <a href="https://github.com/litten/hexo-theme-yilia" target="_blank">Yilia</a> by Litten
      	</div>
    </div>
  </div>
</footer>
    </div>
    
  <link rel="stylesheet" href="/fancybox/jquery.fancybox.css">


<script>
	var yiliaConfig = {
		fancybox: true,
		mathjax: true,
		animate: true,
		isHome: false,
		isPost: true,
		isArchive: false,
		isTag: false,
		isCategory: false,
		open_in_new: false
	}
</script>
<script src="http://7.url.cn/edu/jslib/comb/require-2.1.6,jquery-1.9.1.min.js"></script>
<script src="/js/main.js"></script>






<script type="text/x-mathjax-config">
MathJax.Hub.Config({
    tex2jax: {
        inlineMath: [ ['$','$'], ["\\(","\\)"]  ],
        processEscapes: true,
        skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
    }
});

MathJax.Hub.Queue(function() {
    var all = MathJax.Hub.getAllJax(), i;
    for(i=0; i < all.length; i += 1) {
        all[i].SourceElement().parentNode.className += ' has-jax';                 
    }       
});
</script>

<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>


  </div>
</body>
</html>